package com.molin.edu.info.manager.controller;

import com.molin.edu.info.manager.domain.Student;
import com.molin.edu.info.manager.service.StudentService;

import java.util.ArrayList;
import java.util.Scanner;
/*
* controller 与用户进行交互，不关心数据是否合理。*/
public class StudentController extends BaseStudentController{
    /*
    * 使用抽象类作为模板，重写addStudent方法；
    * 以满足“开闭原则”：一个软件实体如类、模版和函数应该对扩展，对修改关闭；
    * */
    public boolean addStudent() {
        Scanner sc = new Scanner(System.in);
        String id;
        while (true) {
            System.out.println("请输入学生id: ");
            id = sc.nextLine();
            if (studentService.isExsit(id)) {
                System.out.println("学生id重复，请重新输入!");
            } else {
                break;
            }
        }

        System.out.println("请输入学生年龄: ");
        int age = sc.nextInt();
        sc.nextLine();
        System.out.println("请输入学生生日: ");
        String birthday = sc.nextLine();
        System.out.println("请输入学生姓名: ");
        String name = sc.nextLine();
        return studentService.addStudent(id, age, name, birthday);
    }

}
